<?php
/**
 * @file Z_reload.php
 * @package 
 * @subpackage 
 * @version $id: 0.1 UTF-8 2009-3-16 下午08:19:58 $
 * @author LD King (mifunny.info)
 * @copyright Copyright (c) 2007 - 2009 MiFunny China Inc. (http://mifunny.info)
 */
define('DB_FILE', '7tao.db');
// 连接 SQLite 
try {
	$dbh = new PDO("sqlite:".DB_FILE, null, null, array(PDO::ATTR_PERSISTENT => true));
}catch (PDOException $ex){
	die("[SQLite Connect Error]: ".$ex->getMessage().'<br />\n');
}
$dbh->query('PRAGMA encoding = "UTF-8"');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sqlSelect = "SELECT id, title, price FROM taoke";
$result = $dbh->query($sqlSelect);
$rows = $result->fetchAll(PDO::FETCH_BOTH);
if (empty($rows[0])){ //已含有URL
	exit('<div class="box error">数据取得为空！</div>');
}
for ($i=0; $i<count($rows); $i++) {
	$id = $rows[$i]['id'];
	$price = $rows[$i]['title'];
	$title = $rows[$i]['price'];
	$sqlUpdate = "UPDATE taoke SET title='$title', price='$price' WHERE id=$id";
	if ($dbh->exec($sqlUpdate) != 1){
		echo "$id UPDATE ERROE!";
	}else {
		echo "$id   Ha!HA!";	
	}
}
?>